package me.xuym.crawler.dygang.entity;

import com.google.gson.Gson;
import me.xuym.crawler.simpleextension.dispatcher.SimpleDebugDispatcherInput;
import me.xuym.crawler.simpleextension.filter.SimpleCachedFilterInput;

import java.util.Hashtable;
import java.util.Map;

/**
 * Created by broche on 13/09/2017.
 */
public class DYGangDownloadResult implements SimpleCachedFilterInput, SimpleDebugDispatcherInput {
    private long dyid = -1;
    private String type = "未知";
    private String url = "未知";
    private String name = "未知";
    private String size = "未知";

    public long getDyid() {
        return dyid;
    }

    public void setDyid(long dyid) {
        this.dyid = dyid;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSize() {
        return size;
    }

    public void setSize(String size) {
        this.size = size;
    }

    @Override
    public Map<String, String> simpleCachedFilterCheckFields() {
        Map<String, String> fields = new Hashtable<>();
        fields.put("url", getUrl());
        return fields;
    }

    @Override
    public Map<String, String> simpleCachedFilterSaveFields() {
        Map<String, String> fields = new Hashtable<>();
        fields.put("dyid", getDyid() + "");
        fields.put("type", getType());
        fields.put("url", getUrl());
        fields.put("name", getName());
        fields.put("size", getSize());
        return fields;
    }

    @Override
    public String simpleDebugDispatcherContent() {
        return new Gson().toJson(this);
    }
}
